package com.czl.module_activity.adapter

import android.os.Bundle
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.czl.base.binding.command.BindingCommand
import com.czl.base.binding.command.BindingConsumer
import com.czl.base.config.AppConstants
import com.czl.base.data.bean.ActivityProfileListBean
import com.czl.base.data.bean.CommunityResponseBean
import com.czl.module_activity.R
import com.czl.module_activity.databinding.ItemActivityBinding
import com.czl.module_activity.databinding.ItemMyActivityBinding
import com.czl.module_activity.fragment.ActivityListFragment
import com.czl.module_activity.fragment.MyActivityFragment

class MyActivityAdapter(private val fragment: MyActivityFragment) :
    BaseQuickAdapter<ActivityProfileListBean.Record, BaseDataBindingHolder<ItemMyActivityBinding>>(
        R.layout.item_my_activity
    ) {
    override fun convert(
        holder: BaseDataBindingHolder<ItemMyActivityBinding>,
        item: ActivityProfileListBean.Record
    ) {
        holder.dataBinding?.apply {
            data = item
            adapter = this@MyActivityAdapter
            executePendingBindings()
        }
    }

    val onItemClick: BindingCommand<Any> = BindingCommand(BindingConsumer {
        if (it is ActivityProfileListBean.Record){
            fragment.startContainerActivity(
                AppConstants.Router.Activities.F_ACTIVITIES_DETAIL,
                Bundle().apply {
                    putString(
                        AppConstants.BundleKey.ACTIVITY_ID,
                        it.id.toString()
                    )
                    putString(AppConstants.BundleKey.ACTIVITY_STATUS,
                    it.statusTag)
                    putString(AppConstants.BundleKey.COMMUNITY_FROM_PAGER,"MyActivityFragment")
                })
        }
    })
}